package com.zy.web.demo.wenjian;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class zhengze {


    public static void main(String[] args) throws Exception{
        List<String> list = new LinkedList<>();
        String pattern = "(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]";
        Pattern p = Pattern.compile(pattern);
        FileInputStream fileInputStream = new FileInputStream(new File("C:\\Users\\pc\\Desktop\\java.txt"));
        byte[] bytes = new byte[1024];
        int len = 0;
        while ( (len = fileInputStream.read(bytes) ) != -1){

        }
        String line = "";


        Matcher m = p.matcher(line);
        List<String> zy = new LinkedList<>();
        while(m.find()){
            // 存在则把http提取出来存入文本中
            String group = m.group();
            String[] split = group.split("/");
//            System.out.println(split[0]+split[1]+split[2]);
            zy.add(split[0]+split[1]+split[2]);
        }
        List<String> collect = zy.stream().distinct().collect(Collectors.toList());
        for (String s : collect) {
            System.out.println(s);
        }
    }

}
